/**
 * @以秒为单位更新时间
 *
 * @author	 wangshikun <wangshikun2010@gmail.com>
 * @copyright	(c) 2012 wangshikun <wangshikun2010@gmail.com>
 * @license	http://www.opensource.org/licenses/mit-license.php The MIT License
 * @package	default
 * @subpackage	default
 */

#include <stdio.h>
#include <cs50.h>

struct time {
	int hours;
	int minutes;
	int seconds;
};
struct time timeUpdate(struct time now);

int main(int argc, char *argv[]) {
	struct time currentTime, nextTime;

	printf("请输入一个时间：");
	scanf("%d:%d:%d", &currentTime.hours, &currentTime.minutes, &currentTime.seconds);

	nextTime = timeUpdate(currentTime);
	printf("下一秒是：%.2d:%.2d:%.2d\n", nextTime.hours, nextTime.minutes, nextTime.seconds);
}

//以秒为时间更新单位
struct time timeUpdate(struct time now) {
	now.seconds++;

	if (now.seconds == 60) {
		now.seconds = 0;
		now.minutes++;
 
	
		if(now.minutes == 60) {
			now.minutes = 0;
			now.hours++;
		

			if (now.hours == 24) {
				now.hours = 0;
			}
		}
	}

	return now;
}
